﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace equation
{
    public class fun
    {
        private int a, b, c;
        private double delta;

        public fun(int a, int b, int c)
        {
            this.a = a;
            this.b = b;
            this.c = c;
            this.delta = b * b - 4 * a * c;
        }

        public void Count()
        {
            if (delta < 0)
            {
                Console.WriteLine("此方程无实数解");
            }
            else if (delta == 0)
            {
                double x = -b / (2 * a);
                Console.WriteLine("此方程有一个重根：x = {0}", x);
            }
            else
            {
                double x1 = (-b + Math.Sqrt(delta)) / (2 * a);
                double x2 = (-b - Math.Sqrt(delta)) / (2 * a);
                Console.WriteLine("此方程有两个解：x1 = {0}，x2 = {1}", x1, x2);
            }
        }

    };
}
